package com.app.service.impl;

import com.app.mapper.ProcessFlowMapper;
import com.app.model.ProcessFlowModel;
import com.app.model.ProcessFlowModel;
import com.app.service.ProcessFlowService;
import com.app.vo.ProcessFlowVo;
import com.app.vo.ProcessFlowVo;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ProcessFlowServiceImpl extends ServiceImpl<ProcessFlowMapper, ProcessFlowModel> implements ProcessFlowService {

    @Autowired
    private ProcessFlowMapper processFlowMapper;
    @Override
    public ProcessFlowVo getProcessFlowList(Integer page, Integer limit) {
        Page<ProcessFlowModel> page1 = new Page<>(page, limit);
        Page<ProcessFlowModel> processFlowPage = processFlowMapper.selectPage(page1, null);
        List<ProcessFlowModel> processFlowList = processFlowPage.getRecords();

        long count = processFlowPage.getTotal();
        ProcessFlowVo processFlowVo = new ProcessFlowVo();
        processFlowVo.setList(processFlowList);
        processFlowVo.setCount((int) count);
        return processFlowVo;
    }
    //根据类型查
    @Override
    public ProcessFlowVo getByType(Integer page,Integer limit,Integer type) {
        Page<ProcessFlowModel> page1 = new Page<>(page, limit);
        LambdaQueryWrapper<ProcessFlowModel> lqw =new LambdaQueryWrapper<>();
        lqw.eq(ProcessFlowModel::getType,type);
        Page<ProcessFlowModel> processFlowPage = processFlowMapper.selectPage(page1, lqw);
        List<ProcessFlowModel> processFlowList = processFlowPage.getRecords();

        long count = processFlowPage.getTotal();
        ProcessFlowVo processFlowVo = new ProcessFlowVo();
        processFlowVo.setList(processFlowList);
        processFlowVo.setCount((int) count);
        return processFlowVo;
    }
}
